import request from '@/utils/request'

export function createAPI(prefix) {
    const createMethod = (method) => (url, data = {}, header = {}) => {

        let options = {
            url: `/${prefix}/${url}`,
            header,
            method
        }

        if (method == "GET") options.params = data
        if (method == "POST") options.data = data

        return request(options);
    };

    return {
        post: createMethod('POST'),
        get: createMethod('GET')
    };
}